﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects;

namespace MINERP.DAL.InfoConfig
{
    public  class PaperTemplateDAL:DALBase
    {
        private static ObjectQuery<tb_paperTemplate> GetPaperTemplates()
        {
            return DataEntites.tb_paperTemplate.Include("paperFace").Include("paperType").Include("printer");
        }

        /// <summary>
        /// Get PaperTemplate List
        /// </summary>
        /// <returns></returns>
        public static List<tb_paperTemplate> GetPaperTemplateList()
        {
            List<tb_paperTemplate> list = new List<tb_paperTemplate>();
            foreach (var item in GetPaperTemplates())
            {
                list.Add(item);
            }
            return list;
        }
        /// <summary>
        /// Get PaperTemplate object
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static tb_paperTemplate GetPaperTemplateObj(int id)
        {
            return DataEntites.tb_paperTemplate.Include("paperFace").Include("paperType").First(t => t.TempLateId == id);
        }
        /// <summary>
        /// add PaperTemplate 
        /// </summary>
        /// <param name="obj"></param>
        public static void Add(tb_paperTemplate obj)
        {
            DataEntites.AddTotb_paperTemplate(obj);
            DataEntites.SaveChanges();
        }
        /// <summary>
        /// Update paperTemplate
        /// </summary>
        public static void Update()
        {
            DataEntites.SaveChanges();
        }
        /// <summary>
        /// Delete PaperTemplate
        /// </summary>
        /// <param name="obj"></param>
        public static void Delete(tb_paperTemplate obj)
        {
            DataEntites.DeleteObject(obj);
            DataEntites.SaveChanges();
        }

    }
}
